# encoding: utf-8
"""
Vector3D.py

Created by Vivek Bhagwat on 2008-03-20.
Part of physicslibrary project on Google Code.
SVN: http://physicslibrary.googlecode.com/svn/trunk/
"""

import sys
import os

class Vector3D(object):
	def __init__(self, i, j, k):
		super(Vector3D, self).__init__()
		self.i = i
		self.j = j
		self.k = k
	
	def __init(self, theta, phi, magnitude):
		self.i = magnitude * math.cos(theta)
		self.j = magnitude * math.sin(theta)
		self.k = magnitude * sin(phi)
		print magnitude
	
	def __str__(self):
		return "<%d, %d, %d>" % (self.i, self.j, self.k)
	
	def magnitude(self):
		return (self.i**2 + self.j**2 + self.k**2)**0.5
	
	def unit(self):
		mag = self.magnitude()
		return Vector3D(self.i/mag, self.j/mag, self.k/mag)
	
	def add(self, other):
		return Vector3D(self.i+other.i, self.j+other.j, self.k+other.k)
	
	def subtract(self, other):
		return Vector3D(self.i-other.i, self.j-other.j, self.k-other.k)
	
	def dot(self, other):
		return self.i*other.i + self.j*other.j + self.k*other.k
	
	def cross(self, other):
		x = self.j*other.k - self.k*other.j
		y = other.i*self.k - self.i*other.k
		z = self.i*other.j - self.j*other.i
		return Vector3D(x,y,z)
	
"""
def main():
	num = raw_input("How many vectors do you want to build? ")
	vectors = []
	print "Will build", num, "vectors"
	print "Enter the x, y, then z component of each vector"
	
	for i in range(0, int(num)):
		print "vector ", (i+1)
		i = int(raw_input("x: "))
		j = int(raw_input("y: "))
		k = int(raw_input("z: "))
		vectors.append(Vector3D(i,j,k))
		print "<%d, %d, %d>" % (i, j, k)
	
	operation = raw_input("what operation do you want to perform on these two vectors? ") 
	vect = raw_input("On which vectors (give the number in which you submitted)?")
	v1 = vectors[int(vect[0]) - 1]
	v2 = vectors[int(vect[1]) - 1]
	
	print "You chose to",operation,"vectors",vect[0],"and",vect[1]
	
	if operation == "cross":
		print v1, "x", v2, "=", v1.cross(v2)
	if operation == "dot":
 		print v1, "•", v2, "=", v1.dot(v2)
	if operation == "add":
		print v1, "+", v2, "=", v1.add(v2)
	if operation == "subtract":
		print v1, "-", v2, "=", v1.subtract(v2)
"""
if __name__ == '__main__':
	main()

